<?php
/**
 * 客户 
 * @Author: wjf
 * @Date: 2022-11-26 14:48:23
 */
namespace app\crm\model\client;

use think\Model;
use think\model\concern\SoftDelete;

class Ourclients extends Model
{
    /**
     * 开启软删除 
     * @Author: wjf
     * @Date: 2022-12-06 14:10:51
     */    
    use SoftDelete;
    protected $deleteTime = 'delete_time';

    /**
     * 设置当前模型对应的完整数据表名称 
     * @Author: wjf
     * @Date: 2022-11-26 15:03:14
    */ 
    protected $table = 'crm_client';
    /**
     * 自动写入时间戳 
     * @Author: wjf
     * @Date: 2022-11-26 15:25:06
    */  
    protected $autoWriteTimestamp = true;


    /**
      * auto属性自动完成包含新增和更新操作
      * @Author: wjf
      * @Date: 2022-12-01 09:57:42
      */    
    protected $auto = ['super_id' => 1,'status' => 2, 'classify' => 1]; 

        /**
     * 插入转为时间戳
     * @Author: wjf
     * @Date: 2022-11-30 11:43:08
     */  
    public function setFollowTimeAttr($value)
    {
        return strtotime($value);
    }

    /**
     * 遍历转为时间
     * @Author: wjf
     * @Date: 2022-11-30 11:43:34
     */   
    public function getFollowTimeAttr($value)
    {
        return date('Y-m-d H:i:s',$value);
    } 

    public function getGetTimeAttr($value)
    {
        return date('Y-m-d H:i:s',$value);
    }
    /**
     * 状态
     * @Author: wjf
     * @Date: 2022-11-30 11:51:29
     */    
    public function getStatusAttr($value,$data)
    {
        $stutas = [0 => '未成交', 1 => '已成交', 2 => '已转客户', 3 => '无效线索'];
        return $stutas[$data['status']];
    }

    /**
     * 链接联系人表
     * @Author: wjf
     * @Date: 2022-12-06 10:21:14
     */    
    public function Linkman()
    {
        return $this->hasOne('Linkman','client_id','id');
    }
}